# Contributor: Holger Jaekel <holger.jaekel@gmx.de>
# Maintainer: Holger Jaekel <holger.jaekel@gmx.de>
pkgname=sfcgal
pkgver=1.5.1
pkgrel=1
pkgdesc="Library for ISO 19107:2013 and OGC SFA 1.2 for 3D operations"
url="https://sfcgal.gitlab.io/SFCGAL/index.html"
arch="all"
license="LGPL-2.0-or-later"
makedepends="
	boost-dev
	cgal-dev
	cmake
	gmp-dev
	mpfr-dev
	samurai
	"
subpackages="$pkgname-dev"
source="https://gitlab.com/sfcgal/SFCGAL/-/archive/v$pkgver/SFCGAL-v$pkgver.tar.bz2"
builddir="$srcdir/SFCGAL-v$pkgver"

[ "$CARCH" = s390x ] && options="$options !check" # hangs on the CI

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DSFCGAL_BUILD_TESTS="$(want_check && echo ON || echo OFF)" \
		-DSFCGAL_WITH_OSG=OFF \
		-DCMAKE_SKIP_INSTALL_RPATH=ON
	cmake --build build
}

check() {
	ctest --output-on-failure --test-dir build -E "garden-test"
}

package() {
	DESTDIR="$pkgdir" cmake --install build
	# installs tests
	rm -rf "$pkgdir"/usr/bin/*test*
}

sha512sums="
198032844a82d958639ae9199c49a00d782e5a2c9d8e9c06d84febcb630fd1645caf788dda38014930b185785d3fd4236ee9773aaf5c20e95dcc840a466ef41d  SFCGAL-v1.5.1.tar.bz2
"
